package com.atguigu.rabbitmq.eight;

import com.atguigu.rabbitmq.utils.RabbitMqUtils;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;

/**
 * ClassName: Producer
 * Description: 死信队列 之 生产者代码
 * Date: 2023/04/28 PM 4:19:47
 * <p>
 * project: atguigu-rabbitmq
 * package: com.atguigu.rabbitmq.eight
 * email: 1085844536@qq.com
 * version:
 *
 * @author WangGuojian
 */
public class Producer {

    /**
     * 普通交换机的名称
     */
    public static final String NORMAL_EXCHANGE = "normal_exchange";

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMqUtils.getChannel();
        // 死信消息 设置 TTL 时间 time to live 单位是 ms       10000ms = 10s
        // AMQP.BasicProperties properties = new AMQP.BasicProperties()
        //         .builder().expiration("10000").build();

        for (int i = 1; i < 11; i++) {
            String message = "info" + i;
            channel.basicPublish(NORMAL_EXCHANGE, "zhangsan", null, message.getBytes());
        }

    }
}
